<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Add_Prospect extends Page
{
       public $Update = null;
       public $hfCompId = null;
       public $edcontact_num = null;
       public $edcontact_person = null;
       public $Image1 = null;
       public $Button2 = null;
       public $Label5 = null;
       public $Label4 = null;
       public $edBusiness_address = null;
       public $Label3 = null;
       public $edEmail = null;
       public $edcomp_name = null;
       public $Label2 = null;
       public $Label1 = null;
       function Button2JSClick($sender, $params)
       {

       ?>
       window.close();

       <?php

       }

       function Add_ProspectCreate($sender, $params)
       {
       $company_id = $_GET['company_id'];
       $this->hfCompId->setValue($company_id);

       $result_pros = mysql_query("SELECT * FROM prospects_tbl WHERE autoid = '".$this->hfCompId->getValue()."'");
       $row_pros = mysql_fetch_array($result_pros);

       $this->edcomp_name->Text = $row_pros['comp_name'];
       $this->edBusiness_address->Text = $row_pros['business_add'];
       $this->edEmail->Text = $row_pros['email_add'];
       $this->edcontact_person->Text = $row_pros['contact_person'];
       $this->edcontact_num->Text = $row_pros['contact_num'];


       }




       function UpdateClick($sender, $params)
       {
       $query_update = "UPDATE prospects_tbl SET
       comp_name='".$this->edcomp_name->Text."',
       email_add='".$this->edEmail->Text."',
       business_add='".$this->edBusiness_address->Text."',
       contact_person='".$this->edcontact_person->Text."',
       contact_num='".$this->edcontact_num->Text."'
       WHERE autoid='".$this->hfCompId->getValue()."'";
       mysql_query($query_update) or die(mysql_error());

       echo '<script language=javascript>
       window.opener.location.reload();
       alert("Successfully Updated Record!");
       window.close();
       </script>';
       }

}

global $application;

global $Add_Prospect;

//Creates the form
$Add_Prospect=new Add_Prospect($application);

//Read from resource file
$Add_Prospect->loadResource(__FILE__);

//Shows the form
$Add_Prospect->show();

?>